package com.tim.socket;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

public class EchoThread implements Runnable{

	private Socket client = null;
	
	public EchoThread(Socket client){
		this.client = client;
	}
	
	public void run() {
		BufferedReader buf = null;
		PrintStream out = null;
		try{
			System.out.println("连入");
			out = new PrintStream(client.getOutputStream());
			buf = new BufferedReader(new InputStreamReader(client.getInputStream()));
			boolean flag = true;
			while(flag){
				String str = buf.readLine();
				if(str == null || "".equals(str)){
					flag = false;
				}else{
					if("quit".equals(str)){
						flag = false;
					}else{
						out.println("FengWei ECHO : " + str);
					}
				}
			}
			client.close();
		}catch(Exception e){
			
		}
	}

	
}
